#include <iostream>
#include <fstream>
#include "GuiTar.h"

using namespace std;

Guitar * gGuitar = new Guitar[20];
int soDong = 0;

string LoadDuLieu(string cText)
{
	
	string strLine;
	ifstream myFile;
	char * cTenHopAm;
	char * cCachDanh;
	myFile.open(cText);
	
	while (!myFile.eof())
	{
		getline(myFile,strLine,'\t');
		cTenHopAm = (char *)strLine.c_str();
		gGuitar[soDong].m_tenHopAm = cTenHopAm;
		//cout<<cTenHopAm<<endl;

		getline(myFile,strLine,'\n');
		cCachDanh = (char *)strLine.c_str();
		//cout<<cCachDanh<<endl;
		gGuitar[soDong].m_CachDanh = cCachDanh;
		soDong++;
	}
	for (int i = 0; i < soDong; i++)
	{
		gGuitar[i].InGuitar();
	}
	return strLine;
}

bool checkCharHoa(string strCheck)
{
	if (strCheck >= "A" && strCheck <= "Z")
	{
		return true;
	}
	return false;
}

//bool checkDoDaiCachDanh(char cCheckDoDai)
{

	return false;
}

int main()
{
	LoadDuLieu("HopAm.txt");
	cout<<"\n\n";

	string strNhapTenHopAm;
	cout<<"Ban Hay nhap ten hop am ma ban muon tim:"<<endl;
	
	do 
	{
		// NHap ten hop am
		// In ra cach danh
		getline(cin,strNhapTenHopAm);
		for (int i = 0; i < soDong; i++)
		{
			if (checkCharHoa(strNhapTenHopAm) == false)
			{
				return false;
			}
			else
			{
				if (gGuitar[i].m_tenHopAm == strNhapTenHopAm)
				{
					gGuitar[i].InGuitar();
				}
			}
			
		}
	} while (-1);


	system("pause");
	return 0;
}